import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Form_Select extends JDialog {
    private JPanel contentPane;
    private JButton buttonOK;
    private JButton buttonCancel;
    private JButton btn_Add;
    private JButton btn_Edit;
    private JButton btn_Del;
    private JPanel pnl_Operation;
    private JTable table1;
    private JCheckBox chckBx_Delete;
    private JCheckBox ChckBx_Filtr;
    private JTextField textField1;
    private JComboBox comboBox1;
    private JButton обновитьButton;
    private JPanel pnl_Filter;
    private JPanel pnl_Data;

    private int sizeWidth = 500;
    private int sizeHeight = 300;

    public Form_Select() {

        setContentPane(contentPane);
        setModal(true);
        getRootPane().setDefaultButton(buttonOK);

        //Размещаем окно по центру экрана
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int locationX = (screenSize.width - sizeWidth) / 2;
        int locationY = (screenSize.height - sizeHeight) / 2;
        setBounds(locationX, locationY, sizeWidth, sizeHeight);


        buttonOK.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onOK();
            }
        });

        buttonCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        });

// call onCancel() when cross is clicked
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                onCancel();
            }
        });

// call onCancel() on ESCAPE
        contentPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    }

    private void onOK() {
// add your code here
        dispose();
    }

    private void onCancel() {
// add your code here if necessary
        dispose();
    }

//    public static void main(String[] args) {
//        Form_Select dialog = new Form_Select();
//        dialog.pack();
//        dialog.setVisible(true);
//        System.exit(0);
//    }
}
